// 资产管理相关类型定义

export interface AssetCategory {
  id: number
  name: string
  icon: string
  color: string
  total_value: number
  count: number
  balance?: number
  notes?: string
  status?: 'active' | 'inactive'
}

export interface Asset {
  id: number
  name: string
  symbol: string
  category_id: number
  category_name: string
  quantity: number
  purchase_price: number
  current_price: number
  purchase_date: string
  total_value: number
  profit_loss: number
  profit_loss_percentage: number
  notes?: string
}

export interface PortfolioOverview {
  total_value: number
  value: number
  created_at: number
  updated_at: number
  // 计算字段（前端计算）
  total_profit_loss?: number
  total_profit_loss_percentage?: number
  yesterday_change?: number
  yesterday_change_percentage?: number
  total_asset_value?: number
  total_cost?: number
}

export interface PriceData {
  symbol: string
  current_price: number
  change: number
  change_percentage: number
  last_updated: string
}

export interface HistoryPrice {
  date: string
  price: number
  volume?: number
}

export interface PerformanceData {
  period: string
  total_return: number
  annualized_return: number
  volatility: number
  sharpe_ratio: number
  max_drawdown: number
}

// API 请求和响应类型
export interface ApiResponse<T> {
  code: number
  success: boolean
  message: string
  data: T
}

export interface PaginatedResponse<T> {
  items: T[]
  total: number
  page: number
  limit: number
}

// 表单数据类型
export interface AssetFormData {
  name: string
  symbol: string
  category_id: string
  quantity: string
  purchase_price: string
  purchase_date: string
  notes: string
}

export interface CategoryFormData {
  name: string
  icon: string
  color: string
  balance?: number
  notes?: string
  status?: 'active' | 'inactive'
}

// 搜索和过滤类型
export type SortBy = 'name' | 'value' | 'profit' | 'date'
export type SortOrder = 'asc' | 'desc'

export interface AssetFilters {
  category_id?: number
  search_term?: string
  sort_by?: SortBy
  sort_order?: SortOrder
  date_from?: string
  date_to?: string
}